<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>重生之我觉醒了流浪系统</title>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <link type="text/css" rel="stylesheet" href="css/public.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <!--头部-->

        <div class="quan">
            <div id="div1">
                <img src="images/beijing2.jpg">
            </div>
    <header class="publicHeader">
        <h1>流浪家</h1>
        <div class="publicHeaderR">
            <p><span>下午好！</span><span style="color: #fff21b"> 主人</span> , 欢迎你！</p>
            <a href="jsp/logout.do">退出</a>
        </div>
    </header>
    <!--时间-->
    <section class="publicTime">
        <span id="time">2015年1月1日 11:11  星期一</span>
        <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器！（IE10+）</a>
    </section>
    <!--主体内容-->
    <section class="publicMian ">
        <div class="left">
            <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
            <nav>
                <ul class="list">
                    <li><a href="animal.html">动物管理</a></li>
                    <li><a href="adoptive.html">领养者管理</a></li>
                    <li><a href="user.html">用户管理</a></li>
                    <li><a href="update_pass.html">密码修改</a></li>
                    <li><a href="#" @click="logout">退出系统</a></li>
                </ul>
            </nav>
        </div>
        <input type="hidden" id="path" name="path" value="/SMBMS"/>
        <input type="hidden" id="referer" name="referer" value="http://localhost:8080jsp/frame.jsp"/>

        <div class="right">
            <div class="location">
                <strong>你现在所在的位置是:</strong>
                <span>动物管理页面</span>
            </div>
            <div class="search">
                <input name="method" value="query" class="input-text" type="hidden">
                <span>动物名称：</span>
                <input name="queryProductName" type="text" v-model="animalName">
                <span>动物性别：</span>
                <select name="queryProviderId" v-model="gender">
                    <option
                            value="2">公
                    </option>
                    <option
                            value="1">母
                    </option>
                </select>
                <span>健康状况：</span>
                <select name="queryIsPayment" v-model="health">
                    <option value="优秀">优秀</option>
                    <option value="良好">良好</option>
                    <option value="较差">较差</option>
                </select>

                <input value="查 询" type="submit" id="searchbutton" @click="searchAnimal">
                <a href="animal_save.html">动物添加</a>

            </div>
            <!--账单表格 样式和供应商公用-->
            <table class="providerTable" cellpadding="0" cellspacing="0">
                <tr class="firstTr">
                    <th width="10%">动物编码</th>
                    <th width="20%">动物名称</th>
                    <th width="10%">性别</th>
                    <th width="10%">种类</th>
                    <th width="10%">健康状况</th>
                    <th width="10%">出生日期</th>
                    <th width="30%">操作</th>
                </tr>

                <tr v-for="a in animal">
                    <td>
                        <span>{{a.animalCode}}</span>
                    </td>
                    <td>
                        <span>{{a.animalName}}</span>
                    </td>
                    <td>
                        <span>{{a.gender == 1 ? '母' : '公'}}</span>
                    </td>
                    <td>
                        <span>{{a.type}}</span>
                    </td>
                    <td>
                        <span>{{a.health}}</span>
                    </td>
                    <td>
                        <span>{{a.birthday}}</span>
                    </td>
                    <td>
                        <span><a class="viewBill" href="#;" @click="showAnimal(a)">
                            <img src="images/read2.png" alt="查看" title="查看"/>
                             </a>
                        </span>
                        <span><a class="modifyBill" href="#;" @click="updateAnimal(a)"><img
                                src="images/xiugai2.png" alt="修改" title="修改"/></a></span>
                        <span>
                        <a class="deleteBill" href="#" @click="deleteAnimal(a.id)">
                            <img src="images/schu2.png" alt="删除" title="删除"/>
                        </a>
                    </span>
                    </td>
                </tr>

                </tr>


            </table>
            <div style="margin: auto;text-align: center">
                <el-pagination
                        background
                        page-size="10"
                        layout="prev, pager, next"
                        :total="result.total"
                        @current-change="loadAllAnimalDate">
                </el-pagination>
            </div>
        </div>
    </section>

    <!--点击删除按钮后弹出的页面-->
    <div class="zhezhao"></div>
    <div class="remove" id="removeBi">
        <div class="removerChid">
            <h2>提示</h2>
            <div class="removeMain">
                <p>你确定要删除该订单吗？</p>
                <a href="#" id="yes">确定</a>
                <a href="#" id="no">取消</a>
            </div>
        </div>
    </div>


    <footer class="footer">
        版权归汪汪队立大功
    </footer></div>
</div>
<script type="text/javascript" src="js/time.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="calendar/WdatePicker.js"></script>
</body>
</html>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                animal: [],
                animalName: '',
                gender: '',
                health: '',
                result:'',
            }
        },
        methods: {
            loadAllAnimalDate(page = 1) {
                axios({
                    method: 'get',
                    url: 'animal/findAll',
                    params: {
                        page: page
                    }
                }).then(resp => {
                    this.result = resp.data
                    this.animal = this.result.list
                })
            },
            deleteAnimal(id) {
                console.log(id)
                this.$confirm('此操作将永久删除该用户， 是否继续？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(resp => {
                    axios({
                        method: 'get',
                        url: 'animal/delete',
                        params: {
                            id: id,
                        }
                    }).then(resp => {
                        console.log(resp.data)
                        if (resp.data == 1) {
                            this.loadAllAnimalDate(1);
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            searchAnimal() {
                axios({
                    url: 'animal/findAnimal',
                    params: {
                        animalName: this.animalName,
                        gender: this.gender,
                        health: this.health,
                        page: 1,
                        size: 10
                    }
                }).then(resp => {
                    this.result = resp.data
                    this.animal = this.result.list
                })
            },
            showAnimal(a) {
                let key = 'ANIMAL'
                let value = JSON.stringify(a)
                sessionStorage.setItem(key, value);
                window.location.href = 'animal_show.html';
            },
            updateAnimal(animal) {
                let key = 'ANIMAL'
                let value = JSON.stringify(animal)
                sessionStorage.setItem(key, value);
                window.location.href = 'animal_update.html';
            },
            logout(){
                this.$confirm('此操作将退出， 是否继续？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(resp => {
                    axios({
                        url:'animal/logout'
                    }).then(resp=>{
                        window.location.href = 'login.html';
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消退出'
                    });
                });
            }
        },
        created() {
            this.loadAllAnimalDate()
        }
    })
</script>